<?php
#
#
# Copyright TEDECO, 2009. http://tedeco.fi.upm.es
#
# This file is part of kumenya.
#
# Kumenya is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Kumenya is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
?>
<?php
	Interfaz::CheckSession(Accountant);

	$criterias = AccountingAccount::TrialBalanceCriterias();
	
	if (empty($criterias))
		$result = FALSE;
	else {
		// LO TENEMOS TODO A FALTA DE LAS CUENTAS CONTABLES
		unset ($criterias["UidClase"]);
		unset ($criterias[Type]["UidClase"]);
		unset ($criterias[Uid . AccountingAccountsTable . Start]);
		unset ($criterias[Type][Uid . AccountingAccountsTable . Start]);
		unset ($criterias[Uid . AccountingAccountsTable . End]);
		unset ($criterias[Type][Uid . AccountingAccountsTable . End]);

		$accountingAccountFields = AccountingAccount::getFields();
		
		
		// OPENING AND ENDING ACCOUNTING ACCOUNT
		$openingAccountingAccountFields = array();
		$openingAccountingAccountFields = array();
		$accountingAccountChargeFields = array();
		
		if (empty($accountingAccountFields))
			$result = FALSE;
		else {
			foreach ($accountingAccountFields as $type => $vector)
				foreach ($vector as $key => $value) {
					if ($key == AccountNumber ||
						 $key == AccountName) {
							$openingAccountingAccountFields[$type][$key . Start] = $value;
							$endingAccountingAccountFields[$type][$key . End] = $value;
							$accountingAccountChargeFields[$type][$key] = $value;
						}
					else if ($key == Uid) {
						$openingAccountingAccountFields [$type][OpeningAccountingAccountUid] = $value;
						$endingAccountingAccountFields [$type][EndingAccountingAccountUid] = $value;
						$accountingAccountChargeFields [$type][Uid . AccountingAccountsTable] = $value;
					}
				}
			$notEditables = array_merge ($openingAccountingAccountFields[Type], $endingAccountingAccountFields[Type]);
			$control = Interfaz::AddFields ($openingAccountingAccountFields, $endingAccountingAccountFields);
			$result = TRUE;
		}
	}
?>